<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no,minimal-ui">
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
    <meta name="apple-mobile-web-app-title" content="阿福易购">
    <meta content="telephone=no" name="format-detection" />
    <meta content="email=no" name="format-detection" />
    <!-- uc、qq浏览器 -->
    <meta name="screen-orientation" content="portrait">
    <meta name="full-screen" content="yes">
    <meta name="browsermode" content="application">
    <meta name="x5-orientation" content="portrait">
    <meta name="x5-fullscreen" content="true">
    <meta name="x5-page-mode" content="app">
    <meta name="HandheldFriendly" content="true">
    <meta name="MobileOptimized" content="320">
    <meta name="keywords" content="{{$SEO['keywords']}}"/>
    <meta name="description" content="{{$SEO['description']}}"/>
    <meta name="csrf-token" content="{{ csrf_token() }}" />
    <title>搜索_{{$SEO['title']}}</title>
    <link rel="stylesheet" href="{{ asset('/build/css/app.min.css') }}">
</head>
<body ontouchstart="">
<?php
function buildSearchLink($filter,$item){
    if(is_array($item)){
        foreach ($item as $k=>$v){
            $filter[$k] = $v;
        }
    }
    return http_build_query($filter);
}
?>
<header class="ui-header ui-header-stable ui-has-sub-header af-header">
    <ul class="ui-row-flex">
        <li class="ui-col ui-flex ui-flex-pack-start">
            <i ontouchstart="history.back();" class="ui-icon-return"></i>
        </li>
        <li class="ui-col ui-flex ui-flex-pack-center">
            <h1 class="ui-nowrap">@if($filter['keyword']){{$filter['keyword']}}@else 全部 @endif</h1>
        </li>
        <li class="ui-col ui-flex ui-flex-pack-end">
        </li>
    </ul>
    <ul class="ui-row-flex ui-filter-bar">
        <li class="ui-col @if ($filter['sort']=='') current @endif" @if($type=="cat_search") data-href="/cat/{{$filter['cat_id']}}?{{buildSearchLink($filter,['sort'=>''])}}" @elseif($type=="keywords_search") data-href="/search/result?type={{$type}}&{{buildSearchLink($filter,['sort'=>''])}}" @endif>
            综合
        </li>
        <li class="ui-col" @if($type=="cat_search") data-href="/cat/{{$filter['cat_id']}}?{{buildSearchLink($filter,['sort'=>($filter['sort']=='sale_asc')?'sale_desc':'sale_asc'])}}" @elseif($type=="keywords_search") data-href="/search/result?{{buildSearchLink($filter,['sort'=>($filter['sort']=='sale_asc')?'sale_desc':'sale_asc'])}}"  @endif>
            销量 <i class="icon-filter-arrow @if ($filter['sort']=='sale_desc') arrow-down @elseif($filter['sort']=='sale_asc') arrow-up @endif"></i>
        </li>
        <li class="ui-col" @if($type=="cat_search") data-href="/cat/{{$filter['cat_id']}}?{{buildSearchLink($filter,['sort'=>($filter['sort']=='price_asc')?'price_desc':'price_asc'])}}" @elseif($type=="keywords_search") data-href="/search/result?{{buildSearchLink($filter,['sort'=>($filter['sort']=='price_asc')?'price_desc':'price_asc'])}}" @endif>
            价格 <i class="icon-filter-arrow @if ($filter['sort']=='price_desc') arrow-down @elseif($filter['sort']=='price_asc') arrow-up @endif"></i>
        </li>
        <li class="ui-col" @if($type=="cat_search") data-href="/cat/{{$filter['cat_id']}}?{{buildSearchLink($filter,['stock'=>($filter['stock']==1)?0:1])}}" @elseif($type=="keywords_search") data-href="/search/result?{{buildSearchLink($filter,['stock'=>($filter['stock']==1)?0:1])}}" @endif>
            显示有货
        </li>
    </ul>
</header>

@inject('pictureService','App\Interfaces\PictureService')

<div class="ui-container">
    <section class="ui-rec-goods ui-margin-top-0">
        <ul id="scrollLoadGoods" data-url="/search/result?type={{$type}}&{{buildSearchLink($filter,['sort'=>''])}}" class="ui-rec-goods-item">
            @foreach($paginate as $k=>$goods)
            <li @if($k%2==0) class="l" @else class="r" @endif>
                <div class="ui-goods-card">
                    <div data-href="/goods/show/{{$goods->goods_id}}" class="ui-grid-halve-img af-border-b">
                        <span style="background-image:url('{{$pictureService::thumb($goods->goods_thumb),254,254}}')"></span>
                    </div>
                    <div class="ui-goods-info">
                        <h3 data-href="/goods/show/{{$goods->goods_id}}" class="ui-nowrap">{{$goods->goods_name}}</h3>
                        <p><span class="shop-price">¥{{$goods->shop_price}}</span><del class="market-price">¥{{$goods->market_price}}</del></p>
                    </div>
                </div>
            </li>
            @endforeach
        </ul>
        <div class="ui-loading-wrap">
            <p>正在加载中...</p>
            <i class="ui-loading"></i>
        </div>
    </section>
</div>

<script src="{{ asset('/build/lib/zepto.min.js') }}"></script>
<script src="{{ asset('/build/js/frozen.js') }}"></script>
<script src="{{ asset('/build/js/app.min.js') }}"></script>
</body>
</html>